﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SFP.CollisionDetection
{
    public abstract class Reaction
    {
        protected abstract void fromBeneath(CollisionInfo collisionCollisionInfo);
        protected abstract void fromAbove(CollisionInfo collisionCollisionInfo);
        protected abstract void fromLeft(CollisionInfo collisionCollisionInfo);
        protected abstract void fromRight(CollisionInfo collisionCollisionInfo);
        protected abstract void touchesTop(CollisionInfo collisionCollisionInfo);
        protected abstract void touchesBottom(CollisionInfo collisionCollisionInfo);
        protected abstract void touchesLeft(CollisionInfo collisionCollisionInfo);
        protected abstract void touchesRight(CollisionInfo collisionCollisionInfo);

        public void reactToCollision(long setID)
        {
            HashSet<CollisionInfo> collisionCollisionInfoSet;
            Collision.collisionInfoDict.TryGetValue(setID, out collisionCollisionInfoSet);

            foreach (CollisionInfo collisionCollisionInfo in collisionCollisionInfoSet)
            {
                CollisionType collision = collisionCollisionInfo.Collision;

                if (collision == CollisionType.FromAbove)
                {
                    fromAbove(collisionCollisionInfo);
                }
                else if (collision == CollisionType.TouchesTop)
                {
                    touchesTop(collisionCollisionInfo);
                }
                else if (collision == CollisionType.FromBeneathe)
                {
                    fromBeneath(collisionCollisionInfo);
                }
                else if (collision == CollisionType.TouchesBottom)
                {
                    touchesBottom(collisionCollisionInfo);
                }
                else if (collision == CollisionType.FromLeft)
                {
                    fromLeft(collisionCollisionInfo);
                }
                else if (collision == CollisionType.TouchesLeft)
                {
                    touchesLeft(collisionCollisionInfo);
                }
                else if (collision == CollisionType.FromRight)
                {
                    fromRight(collisionCollisionInfo);
                }
                else if (collision == CollisionType.TouchesRight)
                {
                    touchesRight(collisionCollisionInfo);
                }
            }
        }
    }
}
